/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c5aa0;
    text-decoration: none;
    cursor: pointer;
}

.nav {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: none;
    border: 2px solid transparent;
    color: #666;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    background: #f0f4f8;
    color: #2c5aa0;
}

.nav-btn.active {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a8a 100%);
    color: white;
    border-color: #2c5aa0;
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: flex;
    gap: 2rem;
    min-height: calc(100vh - 120px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.sidebar-header h3 {
    color: #2c5aa0;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.category-list {
    margin-bottom: 2rem;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.5rem;
}

.category-item:hover {
    background: #f0f4f8;
}

.category-item.active {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a8a 100%);
    color: white;
}

.category-item i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.category-item span:first-of-type {
    flex: 1;
}

.count {
    background: rgba(255,255,255,0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    min-width: 24px;
    text-align: center;
}

.category-item.active .count {
    background: rgba(255,255,255,0.3);
}

.subject-list h4 {
    color: #666;
    margin-bottom: 1rem;
    font-size: 1rem;
    border-top: 1px solid #eee;
    padding-top: 1rem;
}

.subject-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.3rem;
}

.subject-item:hover {
    background: #f0f4f8;
    color: #2c5aa0;
}

.subject-item.active {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a8a 100%);
    color: white;
}

.subject-item i {
    margin-right: 0.75rem;
    width: 16px;
    text-align: center;
}

/* Content Area */
.content {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Question Container */
.question-container {
    padding: 2rem;
}

/* Panel header styles */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.panel-header h2 {
    margin: 0;
    color: #2c5aa0;
    font-size: 1.8rem;
    font-weight: 600;
}

.clear-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
    position: relative;
    overflow: hidden;
}

.clear-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.clear-btn:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.clear-btn:hover::before {
    left: 100%;
}

.clear-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.clear-btn i {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.clear-btn:hover i {
    transform: scale(1.1);
}

.question-header {
    background: #f0f4f8;
    color: #2c5aa0;
}

.question-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.question-type {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a8a 100%);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.question-number {
    color: #666;
    font-weight: 500;
}

.question-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: none;
    border: 2px solid #ddd;
    color: #666;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    border-color: #2c5aa0;
    color: #2c5aa0;
}

.action-btn.active {
    background: #ff6b6b;
    border-color: #ff6b6b;
    color: white;
}

/* Question Content */
.question-content {
    margin-bottom: 2rem;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: #333;
    font-weight: 700;
    transition: color 0.3s ease;
}

/* Different colors for different question types */
.question-type-single .question-text {
    color: #2563eb; /* Blue for single choice */
}

.question-type-multiple .question-text {
    color: #dc2626; /* Red for multiple choice */
}

.question-type-judge .question-text {
    color: #059669; /* Green for true/false */
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.option:hover {
    border-color: #2c5aa0;
    background: #f8fafc;
}

.option.selected {
    border-color: #2c5aa0;
    background: #eff6ff;
}

.option.correct {
    border-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
}

.option.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.option-label {
    background: #f3f4f6;
    color: #374151;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 1rem;
    flex-shrink: 0;
}

.option.selected .option-label {
    background: #2c5aa0;
    color: white;
}

.option.correct .option-label {
    background: #10b981;
    color: white;
}

.option.wrong .option-label {
    background: #ef4444;
    color: white;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

/* Question Controls */
.question-footer {
    margin-top: 2rem;
}

.question-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a8a 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(44, 90, 160, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Answer Feedback */
.answer-feedback {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.answer-feedback.correct {
    background: #ecfdf5;
    border: 2px solid #10b981;
}

.answer-feedback.wrong {
    background: #fef2f2;
    border: 2px solid #ef4444;
}

.feedback-content {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.feedback-result {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.feedback-result.correct {
    color: #065f46;
}

.feedback-result.wrong {
    color: #991b1b;
}

.feedback-explanation {
    color: #374151;
    line-height: 1.6;
    width: 100%;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
}

/* Ensure question container maintains consistent width */
.question-container {
    padding: 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Content area width constraint */
.content {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

/* Statistics Panel */
.stats-panel {
    padding: 2rem;
}

.stats-panel h2 {
    color: #2c5aa0;
    margin-bottom: 2rem;
    font-size: 1.8rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    background: #e5e7eb;
    color: #6b7280;
}

.stat-icon.correct {
    background: #ecfdf5;
    color: #10b981;
}

.stat-icon.wrong {
    background: #fef2f2;
    color: #ef4444;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2c5aa0;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #6b7280;
    font-size: 0.9rem;
}

.progress-section h3 {
    color: #374151;
    margin-bottom: 1rem;
}

.progress-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.progress-item:last-child {
    border-bottom: none;
}

.progress-label {
    font-weight: 500;
    color: #374151;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2c5aa0, #1e3a8a);
    transition: width 0.3s ease;
}

/* Favorites and Wrong Questions Panels */
.favorites-panel,
.wrong-panel {
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.favorites-panel h2,
.wrong-panel h2 {
    color: #2c5aa0;
    margin-bottom: 2rem;
    font-size: 1.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(44, 90, 160, 0.1);
}

.question-item {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.question-item:hover {
    border-color: #2c5aa0;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.question-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.question-item-type {
    background: #2c5aa0;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.question-item-text {
    color: #374151;
    line-height: 1.5;
}

/* Mobile Menu */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #2c5aa0;
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(44, 90, 160, 0.3);
    z-index: 1000;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* No Questions State */
.no-questions {
    text-align: center;
    padding: 3rem 2rem;
    color: #6b7280;
}

.no-questions h3 {
    margin-bottom: 1rem;
    color: #374151;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        order: 2;
    }
    
    .content {
        order: 1;
    }
    
    .question-container {
        padding: 1.5rem;
    }
    
    .question-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .question-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav {
        display: none;
    }
    
    .header .container {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem 0;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    .question-container {
        padding: 1rem;
    }
    
    .option {
        padding: 0.75rem;
    }
    
    .option-label {
        width: 28px;
        height: 28px;
        margin-right: 0.75rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .sidebar,
    .question-controls,
    .mobile-menu-toggle {
        display: none;
    }
    
    .main-container {
        padding: 0;
    }
    
    .content {
        box-shadow: none;
        border-radius: 0;
    }
}

/* Hide subject progress section */
.progress-section {
    display: none !important;
    visibility: hidden;
}

/* Hide subject classification section in sidebar */
.subject-list {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
}